package net.wwang.blog.pojo;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import javax.persistence.Transient;
import java.io.Serializable;
import java.sql.Timestamp;

@EntityListeners(AuditingEntityListener.class)
@Data
@NoArgsConstructor
@Entity
@Table(name = "user")
public class User implements Serializable {

  private static final long serialVersionUID = 8399991856329298718L;
  @Id
  @Column(name = "id")
  private String id;
  @Column(name = "username")
  private String username;
  @Column(name = "password")
  private String password;
  @Column(name = "avatar")
  private String avatar;
  @Column(name = "tel")
  private String tel;
  @Column(name = "email")
  private String email;
  @Column(name = "sign")
  private String sign;
  @Column(name = "state")
  private String state;
  @Column(name = "register_ip")
  private String registerIp;
  @Column(name = "login_ip")
  private String loginIp;
  @CreatedDate
  @Column(name = "create_time")
  private Timestamp createTime;
  @LastModifiedDate
  @Column(name = "modify_time")
  private Timestamp updateTime;

  @Transient
  private String roles;


  public User(String id, String username, String avatar, String email, String sign, String tel, String state, String registerIp, String loginIp, Timestamp createTime, Timestamp updateTime){
    this.id = id;
    this.username = username;
    this.avatar = avatar;
    this.email = email;
    this.sign = sign;
    this.tel = tel;
    this.state = state;
    this.registerIp = registerIp;
    this.loginIp = loginIp;
    this.createTime = createTime;
    this.updateTime = updateTime;
  }
}
